﻿namespace EFS.RC.Survey.Controls.Common
{
	public static class Functions
	{
		#region Properties
		/// Property HostFullUrl: Get
		public static System.String HostFullUrl
		{
			get
			{
				// crete url
				System.Text.StringBuilder sbUrl = new System.Text.StringBuilder();
				sbUrl.AppendFormat("{0}://{1}:{2}",
					System.Windows.Application.Current.Host.Source.Scheme,
					System.Windows.Application.Current.Host.Source.Host,
					System.Windows.Application.Current.Host.Source.Port);

				// ok
				return sbUrl.ToString();
			}
		}
		#endregion

		#region Utilities
		/// Shows an error message
		public static void ShowErrorMessage(System.String error)
		{
			System.Windows.MessageBox.Show(error, "Error", System.Windows.MessageBoxButton.OK);
		}

		/// Shows an error message
		public static void ShowErrorMessage(
			System.String customError,
			System.Exception ex)
		{
			// create builder
			System.Text.StringBuilder sbErr = new System.Text.StringBuilder();
			sbErr.Append(customError);

			// test ex
			if (null != ex && EFS.Common.Verify.String(ex.Message))
			{
				sbErr.AppendFormat("{0}{0}{1}",
					System.Environment.NewLine,
					ex.Message);
			}

			// show
			System.Windows.MessageBox.Show(sbErr.ToString(), "Error", System.Windows.MessageBoxButton.OK);
		}

		/// ShowSuccessMessage
		public static void ShowSuccessMessage(System.String message)
		{
			System.Windows.MessageBox.Show(message, "Operation completed", System.Windows.MessageBoxButton.OK);
		}
		#endregion
	}

}